local blaze = require "blaze"
local game = require "club.threecard.hbsl"

local GameObject = require "entities.interfaces.GameObject"
local Client = require "entities.interfaces.Client"
local Player = require "entities.interfaces.Player"

local M = game.kbe.entity("HBSLPlayer", GameObject, Client, Player)

function M:__init__()
    GameObject.__init__(self)
    Client.__init__(self)
    Player.__init__(self)
end

function M:grab()
    self:cellCall("grab")
end

function M:send(amount, no)
    self:cellCall("send", amount, no)
end

function M:req_player_record()
    self:cellCall("req_player_record")
end

function M:onEnterWorld()
    game.store.gameplay.on_player_enter(self)
end

function M:onLeaveWorld()
    game.store.gameplay.on_player_leave(self)
end

function M:on_self_grab(amount)
    self.log.debug(string.format("自己抢到红包: %s", amount))
    game.store.gameplay.on_self_grab(amount)
end

function M:on_grab()
    self.log.debug(string.format("玩家抢红包：%s", self.id))
    game.store.gameplay.on_grab(self)
end

function M:on_send(amount, count)
    self.log.debug(string.format("玩家发红包：%s amount:%s count:%s", self.id, amount, count))
    game.store.gameplay.on_send({player = self, amount = amount, count = count})
end

function M:on_player_record_back(records)
    self.log.debg(string.format("红包记录：%s ", records))
end

function M:on_game_init(scene)
    self.log.debug(string.format("on_game_init scene=%s", game.dump(scene)))
    game.store.gameplay.on_game_init(scene)
end

return M